# 定义编译器和编译选项
CXX = g++
CXXFLAGS = -Wall -std=c++11

# 定义目标文件
SERVER_SRC = server.cpp
CLIENT_SRC = client.cpp
SERVER_OBJ = server.o
CLIENT_OBJ = client.o
EXEC_SERVER = server
EXEC_CLIENT = client

# 默认目标
all: $(EXEC_SERVER) $(EXEC_CLIENT)

# 编译服务器
$(EXEC_SERVER): $(SERVER_OBJ)
	$(CXX) $(CXXFLAGS) -o $(EXEC_SERVER) $(SERVER_OBJ)

# 编译客户端
$(EXEC_CLIENT): $(CLIENT_OBJ)
	$(CXX) $(CXXFLAGS) -o $(EXEC_CLIENT) $(CLIENT_OBJ)

# 编译服务器源文件
$(SERVER_OBJ): $(SERVER_SRC)
	$(CXX) $(CXXFLAGS) -c $(SERVER_SRC)

# 编译客户端源文件
$(CLIENT_OBJ): $(CLIENT_SRC)
	$(CXX) $(CXXFLAGS) -c $(CLIENT_SRC)

# 清理编译生成的文件
clean:
	rm -f $(SERVER_OBJ) $(CLIENT_OBJ) $(EXEC_SERVER) $(EXEC_CLIENT)

.PHONY: all clean
